/*	
 * Authors: Ken YANG <spng.yang@gmail.com>
 * 	
 * Mammoth client main program
 *
 * Copyright (C) 2007-2008 Ken YANG
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation, version 2. 
 * THIS SOFTWARE COMES "AS IS" WITHOUT ANY WARRANTIES.
 */

#include "host_order.h"

/* 
 * Show what byte order your host use 
 *
 * return value:
 *
 * 1:	little endian
 * 0:	big endian
 * <0:	error
 *
 * */
int host_order()
{
	union un
	{
		short s;
		char c[sizeof(short)];
	}bo;

	bo.s=0x0102;

	/* little endian */
	if(bo.c[0]==2 && bo.c[1]==1)
		return 1;
	/* big endian */
	if(bo.c[0]==1 && bo.c[1]==2)
		return 0;
	else 
		return -1;

}


